package common;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 列表分组
 *
 * @author K
 * @date 2022-01-24 18:19
 */
public class ListGrouping {

    /**
     * 每200个元素分为一组
     */
    public static void group() {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < 1950; i++) {
            list.add(i + 1);
        }

        int count = 1;
        for (int i = 0; i < list.size(); i += 200, count++) {
            int toIndex = Math.min(count * 200, list.size());
            List<Integer> subList = list.subList(i, toIndex);
            String s = subList.stream().map(String::valueOf).collect(Collectors.joining(","));
            System.out.println(s);
        }
    }


}
